﻿using AutoMapper;
using HuaHan.WorkTicket.Domain;
using HuaHan.WorkTicket.Domain.Model;
using HuaHan.WorkTicket.Domain.Repositories;
using HuaHan.WorkTicket.Domain.Repositories.EntityFramework;
using HuaHan.WorkTicket.ServiceContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WorkTicket.Application.Implementation
{
    public class ColorServiceImpl : BaseServiceImpl<Color>,IColorService
    {

        #region Private Fields
        private UnitOfWork unitOfWork = new UnitOfWork();
        #endregion

        public ColorServiceImpl()
        {
            base.Repository = unitOfWork.ColorRepository;
            base.UnitOfWork = this.unitOfWork;
        }

        public bool CheckNameExisted(string name, Guid id)
        {
            var count = base.Repository.GetAll().Where(c => c.Name == name && c.ColorID != id).Count();
            if (count > 0)
                return false;
            else
                return true;
        }

    }
}
